package com.bdqn.springbootwebsocket.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;

@Controller
public class WebsocketController {
    @RequestMapping("/login")
    public String login() {
        return "login";
    }

    @RequestMapping("/doLogin")
    public String doLogin(String username, String password, HttpSession session) {
        if (password.equals("123456")) {
            //将用户的登录信息存入HttpSession
            session.setAttribute("user", username);
            return "main";
        } else {
            return "login";
        }
    }
}
